<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!--360浏览器优先以webkit内核解析-->


    <title> - 主页示例</title>

    <link rel="shortcut icon" href="../../src/main/resources/templates/admin/favicon.ico"> <link href="../../src/main/resources/templates/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../../src/main/resources/templates/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="../../src/main/resources/templates/static/admin/css/animate.css" rel="stylesheet">
    <link href="../../src/main/resources/templates/static/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        
			<div class="row">
			    <div class="col-sm-12">
			        <div class="ibox float-e-margins center">
			            <div class="ibox-title ">
			                <h5>操作日志记录</h5>
			            </div>
			            <div class="mytab">
							<table id="table" class="table table-hover"></table>
			            </div>

			        </div>
					
			    </div>
        </div>
	</div>
</body>
	
	<!-- 全局js -->
	
	<script src="../../src/main/resources/templates/static/admin/js/jquery.min.js?v=2.1.4"></script>
	<script src="../../src/main/resources/templates/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
	<script src="../../src/main/resources/templates/static/admin/js/plugins/footable/footable.all.min.js"></script>
		
	<!-- 自定义js -->
	<script src="../../src/main/resources/templates/static/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	 <script src="../../src/main/resources/templates/static/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	 <script src="../../src/main/resources/templates/static/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	 
	 
	<script src="../../src/main/resources/templates/static/admin/js/content.js?v=1.0.0"></script>
	<script>
		
	$(function() {
		$.ajax({
		        type: "get",
		        url: "http://test.wslhome.top/admin/getActivityAll/v1",
		        data:{"status":1},
		        dataType: "json",
		        success: function (msg) {
					console.log(msg);
		            if (msg.data) {
		                var map = {};
						map.total = msg.data.total;
						map.rows = msg.data.records;
		                //将数据库中获取到的数据渲染到id为"table"的这个表格中
						console.log(map);
		                $('#table').bootstrapTable("load", msg.data.records);
		            }
		        }
		    })
			
	    $('#table').bootstrapTable({
	        method: "get",//请求方式
	        striped: true,//是否隔行变色
	        singleSelect: false,
	        dataType: "json",
	        pagination: true, //分页
	        pageSize: 10,//每页的记录行数
	        pageNumber: 1,//初始化加载第一页，默认第一页
	        search: false, //显示搜索框
	        // contentType: "application/x-www-form-urlencoded",
	        queryParams: null,
	        columns : [ {
	            title : 'id',
	            field : 'id',
	            sortable : true
	        }, {
	            title : '商品名',
	            field : 'goodsName',
	            sortable : true
	        }, {
	            title : '开始时间',
	            field : 'startTime',
	        }, {
	            title : '结束时间',
	            field : 'endTime',
				sortable : true
	        } , {
	            title : '创建时间',
	            field : 'creatTime',
				sortable : true
	        }, {
	            title : '商品列表',
	            field : 'skuList',
				formatter : function(value,row, index){   //主要配置在这里
				console.log(row.id)
				                return row.id;
				            }
	        }] 
	    })
	 
	    // 定义删除、更新操作
	    function option(value, row, index) {
	        var htm = '<button id="delUser" userId='
	                + value
	                + ' onclick="delUser(this)">删除</button><button id="dupUser" onclick="updUser('
	                + value + ')">修改</button>'
	        return htm;
	    }
	 
	    // 查询按钮事件
	    $('#search_btn').click(function() {
	        $('#mytab').bootstrapTable('refresh', {
	            url : path + '/user/list'
	        });
	    })
	 
	    // 添加用户
	    $("#userAdd").on("click", function() {
	        layer.open({
	            type : 2,
	            title : '添加用户',
	            area : [ '500px', '440px' ],
	            fix : false, // �
	            content : path + '/user/pageAdd',
	            end : function() {
	                $("#mytab").bootstrapTable('refresh', {
	                    url : path + "/user/list"
	                });
	            }
	        });
	    });
	 
	})
	 
	// 删除用户
	function delUser(dom) {
	   
	    var mymessage = confirm("确认删除嘛？");
	    if (mymessage == true) {
	        $.ajax({
	            url : path + '/user/' + $(dom).attr("userId"),
	            type : 'delete',
	            success : function(data) {
	                $(dom).parent().parent().hide();
	            },
	            error : function(data){
	                alert("服务器繁忙")
	            }
	        });
	    }
	}
	 
	// 编辑用户
	function updUser(id) {
	    layer.open({
	        type : 2,
	        title : '编辑用户',
	        area : [ '500px', '440px' ],
	        fix : false, // �
	        content : path + '/user/pageUpd/' + id,
	        end : function() {
	            $("#mytab").bootstrapTable('refresh', {
	                url : path + "/user/list"
	            });
	        }
	    });
	}
	 
	// 获取项目路径
	function getContextPath() {
	    var currentPath = window.document.location.href;
	    var pathName = window.document.location.pathname;
	    var pos = currentPath.indexOf(pathName);
	    var localhostPath = currentPath.substring(0, pos);
	    var projectName = pathName
	            .substring(0, pathName.substr(1).indexOf('/') + 1);
	    return (localhostPath + projectName);
	}

	 
	</script>
	
</html>		